import 'package:flutter_admin/utils/utils.dart';

class PurchaseEvaluationDetail {

  String? id;
  String? evaluationId;
  String? templateId;
  String? templateName;
  String? projectId;
  String? projectName;
  String? assessmentContent;
  String? evaluationCriteria;
  String? weightScore;
  String? actualDetails;
  String? actualScore;
  String? evaluationOpinions;
  String? createUid;
  String? createDate;
  String? writeUid;
  String? writeDate;
  String? fileCode;

  PurchaseEvaluationDetail({
    this.id,
    this.evaluationId,
    this.templateId,
    this.templateName,
    this.projectId,
    this.projectName,
    this.assessmentContent,
    this.evaluationCriteria,
    this.weightScore,
    this.actualDetails,
    this.actualScore,
    this.evaluationOpinions,
    this.createUid,
    this.createDate,
    this.writeUid,
    this.writeDate,
    this.fileCode,
  });

  PurchaseEvaluationDetail copyWith({
    String? id,
    String? evaluationId,
    String? templateId,
    String? projectId,
    String? assessmentContent,
    String? evaluationCriteria,
    String? weightScore,
    String? actualDetails,
    String? actualScore,
    String? evaluationOpinions,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
    String? fileCode,
  }) {
    return new PurchaseEvaluationDetail(
      id: id ?? this.id,
      evaluationId: evaluationId ?? this.evaluationId,
      templateId: templateId ?? this.templateId,
      projectId: projectId ?? this.projectId,
      assessmentContent: assessmentContent ?? this.assessmentContent,
      evaluationCriteria: evaluationCriteria ?? this.evaluationCriteria,
      weightScore: weightScore ?? this.weightScore,
      actualDetails: actualDetails ?? this.actualDetails,
      actualScore: actualScore ?? this.actualScore,
      evaluationOpinions: evaluationOpinions ?? this.evaluationOpinions,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
      fileCode: fileCode ?? this.fileCode,
    );
  }

  @override
  String toString() {
    return '''PurchaseEvaluationDetail{
      id: id,
      evaluationId: evaluationId,
      templateId: templateId,
      projectId: projectId,
      assessmentContent: assessmentContent,
      evaluationCriteria: evaluationCriteria,
      weightScore: weightScore,
      actualDetails: actualDetails,
      actualScore: actualScore,
      evaluationOpinions: evaluationOpinions,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
      fileCode: fileCode,
    }''';
  }

  @override
  bool operator ==(Object other) => identical(this, other) || (
      other is PurchaseEvaluationDetail &&
          runtimeType == other.runtimeType
          && id== other.id
          && evaluationId== other.evaluationId
          && templateId== other.templateId
          && projectId== other.projectId
          && assessmentContent== other.assessmentContent
          && evaluationCriteria== other.evaluationCriteria
          && weightScore== other.weightScore
          && actualDetails== other.actualDetails
          && actualScore== other.actualScore
          && evaluationOpinions== other.evaluationOpinions
          && createUid== other.createUid
          && createDate== other.createDate
          && writeUid== other.writeUid
          && writeDate== other.writeDate
          && fileCode== other.fileCode
   );


  factory PurchaseEvaluationDetail.fromMap(Map<String, dynamic> map) {
    return new PurchaseEvaluationDetail(
      id: map['id']!=false?map['id'].toString() as String?:"",
      evaluationId: map['evaluation_id']!=false?map['evaluation_id'].toString() as String?:"",
      templateId: map['template_id']!=false?map['template_id'].toString() as String?:"",
      templateName: map['template_id_name']!=false?map['template_id_name'].toString() as String?:"",
      projectId: map['project_id']!=false?map['project_id'].toString() as String?:"",
      projectName: map['project_id_name']!=false?map['project_id_name'].toString() as String?:"",
      assessmentContent: map['assessment_content']!=false?map['assessment_content'].toString() as String?:"",
      evaluationCriteria: map['evaluation_criteria']!=false?map['evaluation_criteria'].toString() as String?:"",
      weightScore: map['weight_score']!=false?map['weight_score'].toString() as String?:"",
      actualDetails: map['actual_details']!=false?map['actual_details'].toString() as String?:"",
      actualScore: map['actual_score']!=false?map['actual_score'].toString() as String?:"",
      evaluationOpinions: map['evaluation_opinions']!=false?map['evaluation_opinions'].toString() as String?:"",
      createUid: map['create_uid']!=false?map['create_uid'].toString() as String?:"",
      createDate: map['create_date']!=false?map['create_date'].toString() as String?:"",
      writeUid: map['write_uid']!=false?map['write_uid'].toString() as String?:"",
      writeDate: map['write_date']!=false?map['write_date'].toString() as String?:"",
      fileCode: map['file_code']!=false?map['file_code'].toString() as String?:"",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'evaluationId': this.evaluationId,
      'templateId': this.templateId,
      'projectId': this.projectId,
      'assessmentContent': this.assessmentContent,
      'evaluationCriteria': this.evaluationCriteria,
      'weightScore': this.weightScore,
      'actualDetails': this.actualDetails,
      'actualScore': this.actualScore,
      'evaluationOpinions': this.evaluationOpinions,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
      'fileCode': this.fileCode,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.evaluationId != null && this.evaluationId != '')
        ['evaluation_id', '=', int.parse(this.evaluationId!)],
    ];
    //if(list.length==0){
    //  list.add(['id','!=',null]);
    //}
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'evaluation_id': this.evaluationId,
      'template_id': this.templateId,
      'project_id': this.projectId,
      'assessment_content': this.assessmentContent,
      'evaluation_criteria': this.evaluationCriteria,
      'weight_score': this.weightScore,
      'actual_details': this.actualDetails,
      'actual_score': this.actualScore,
      'evaluation_opinions': this.evaluationOpinions,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
      'file_code': this.fileCode,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}